package com.cs.cssupplier.controller;


import com.cs.cssupplier.domain.CsAccess;
import com.cs.cssupplier.service.CsAccessService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.security.utils.SecurityUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @Author：lyj
 * @Package：com.cs.cssupplier.controller
 * @Project：RuoYi-Cloud-master
 * @name：CsAccessController
 * @Date：2024/11/11 17:04
 * @Filename：CsAccessController
 */

@RestController
@RequestMapping("/access")
public class CsAccessController extends BaseController {
    @Resource
    private CsAccessService csAccessService;

    /**
     * 查询供应商准入id
     * @param zrid
     * @return
     */
    @GetMapping(value = "cd/{zrid}")
    public AjaxResult accessId(@PathVariable("zrid")Long zrid){
        System.out.println(AjaxResult.success(csAccessService.selectCsAccessZrid(zrid)));
        return AjaxResult.success(csAccessService.selectCsAccessZrid(zrid));
    }

    /**
     * 供应商准入分页查询
     * @param csAccess
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo list(CsAccess csAccess){
        System.out.println("dasdsdasds"+csAccess);
        startPage();
        List<CsAccess> list=csAccessService.selectAccessList(csAccess);
        return getDataTable(list);
    }

    /**
     * 修改供应商准入
     * @param csAccess
     * @return
     */
    @PutMapping
    public AjaxResult updateAccess(@RequestBody CsAccess csAccess){
        System.out.println(csAccessService.updateAccess(csAccess));
        return toAjax(csAccessService.updateAccess(csAccess));
    }

    /**
     * 删除供应商准入
     * @param zr_ids
     * @return
     */
    @DeleteMapping("/{zr_ids}")
    public AjaxResult remove(@PathVariable Long [] zr_ids){
        return toAjax(csAccessService.deleteListAccess(zr_ids));
    }
}
